package com.erp.erp_servers.Seal.imp;

import com.erp.erp_dao.Seal.ISealDAO;
import com.erp.erp_entitys.Seal.SealEntity;
import com.erp.erp_entitys.Seal.SealEntityExample;
import com.erp.erp_servers.Seal.ISealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ImpSealService
 * @Description TODO
 * @Author songjizhen
 * @Date 2020-06-30 21:05
 * @Version 1.0
 */
@Service
public class ImpSealService implements ISealService {
    @Autowired
    ISealDAO sealDAO;
    /**
     * 根据主键删除印章
     *
     * @param id
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return sealDAO.deleteByPrimaryKey(id);
    }

    /**
     * 新增印章信息
     *
     * @param record
     * @return
     */
    @Override
    public int insertSelective(SealEntity record) {
        return sealDAO.insertSelective(record);
    }

    /**
     * 查询印章信息
     *
     * @param record
     * @return
     */
    @Override
    public List<SealEntity> selectByExample(SealEntity record) {
        SealEntityExample example=new SealEntityExample();
        SealEntityExample.Criteria criteria = example.createCriteria();
        criteria.andCompanyCodeEqualTo(record.getCompanyCode());
        List<SealEntity> sealEntities = sealDAO.selectByExample(example);
        return sealEntities;
    }

    @Override
    public SealEntity selectByPrimaryKey(Integer id) {
        return sealDAO.selectByPrimaryKey(id);
    }

    /**
     * 更新印章信息
     *
     * @param record
     * @param record
     * @return
     */
    @Override
    public int updateByExampleSelective(SealEntity record) {
         SealEntityExample example=new SealEntityExample();
        SealEntityExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(record.getId());
        int num = sealDAO.updateByExampleSelective(record, example);
        return num;
    }

    @Override
    public int updateByPrimaryKeySelective(SealEntity record) {
        return sealDAO.updateByPrimaryKeySelective(record);
    }
}
